/**
 * 
 */
package com.nouvasys.sample.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;

import com.nouvasys.sample.dao.EmployeeDAO;
import com.nouvasys.sample.model.Address;
import com.nouvasys.sample.model.Employee;
import com.nouvasys.sample.model.Role;
import com.nouvasys.sample.spring.SpringBeanFactory;

/**
 * @author Ashwath
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		ApplicationContext ctx = SpringBeanFactory.getApplicationContext();
		
		Employee emp = new Employee();
		emp.setEmployeeID(1);
		emp.setFirstName("ashwath");
		emp.setAge(26);
			
		Address adr1 = new Address();
		adr1.setAddressId(1);
		adr1.setFirstLine("3, matru shakti");
		adr1.setSecondLine("subash rd");
		adr1.setCity("cultural hub");
		adr1.setPincode(421202);
		adr1.setEmployee(emp);
		
		Address adr2 = new Address();
		adr2.setAddressId(2);
		adr2.setFirstLine("sagar tech");
		adr2.setSecondLine("sakinaka");
		adr2.setCity("mumbai");
		adr2.setPincode(400067);
		adr2.setEmployee(emp);
		
		Role r = new Role();
		//r.setEmployeeId(1);
		r.setRoleName("Product Lead");
		r.setEmployee(emp);
		
		List addlist = new ArrayList();
		addlist.add(adr1);
		addlist.add(adr2);
				
		emp.setAddressList(addlist);
		emp.setRole(r);
		EmployeeDAO empdao = (EmployeeDAO)ctx.getBean("employeeService");
		//empdao.addEmployee(emp);
		
		//empdao.deleteEmployee(emp);
		
		List<Employee> employees =  empdao.searchEmployee("ash");
		for (Employee employee : employees) {
			System.out.println(employee.getFirstName());
			System.out.println(employee.getRole().getRoleName());
		}


	}

}
